<?php
/**
 * @file
 * Returns the HTML for comments.
 *
 * Complete documentation for this file is available online.
 * @see https://drupal.org/node/1728216
 */

$new_comment = new stdClass;
$new_comment->nid = $comment->nid;
$new_comment->pid = $comment->cid;
//$form = drupal_get_form('comment_form', $new_comment);
$form = drupal_get_form('inner_comment_form_' . $comment->cid, 'inner_comment_form_', $new_comment);

$author_user = user_load($comment->uid);
$user_pic_uri = "";
if (!empty($author_user->picture)) {
    $user_pic_uri = $author_user->picture->uri;
} else {
    $user_pic_uri = "public://user-default.png";
}

$user_pic_url = image_style_url("48x48", $user_pic_uri);
// dsm($author_user);

?>
<article class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

    <?php if ($comment->pid == 0) {
      print "<div class='date'>";
      print "<span class='day'>" . format_date($comment->created, 'custom', 'd') . "</span>";
      print "<span class='month'>" . format_date($comment->created, 'custom', 'M') . "</span>";
      print "</div>";
      // print $picture;
      print "<a class='user-picture' href='/user/" . $comment->uid . "'><img src='" . $user_pic_url . "'></a>";
      //print l(t('Back to top'), '#', array('attributes' => array('class' => 'btn back-to-top')));
      print "<a href='#' class='btn back-to-top'>" . t('Back to top') . "</a>";
    } ?>

    <div class="comment-body">
      <?php
        hide($content['links']);
        print "<h4>" . render($author) . "</h4>";
        print render($content);
      ?>
    </div>

    <div class="time-n-links">
    <?php 
      print "<div class='time-ago'>" . format_interval((time() - $comment->created), 2) . " ago</div>"; 
      print render($content['links']);
    ?>
    </div>

    <?php
      if ($comment->pid == 0)
      { 
        print render($form);
      } 
    ?>

</article>
